<template>

    <el-container class="home-container">
      <!--头部-->
      <el-header>
        <div>
        <span style="margin-left:20px;">
          <img
            src=""
            width="250px;"
            height="100%;"
            alt
            srcset
          />
        </span>
        </div>
        <el-dropdown>
          <div class="block">
            <el-avatar  :size="50" style="cursor: pointer;"></el-avatar>
          </div>
          <el-dropdown-menu slot="dropdown" trigger="click">
            <el-dropdown-item>
              <span type="danger"  @click="goProfile"><span class="el-icon-house"></span> &nbsp;系统首页</span>
            </el-dropdown-item>

            <el-dropdown-item>

              <span type="danger" ><span class="el-icon-ship"></span> &nbsp;交流讨论</span>

            </el-dropdown-item>

            <el-dropdown-item>
              <span type="danger" @click="logout" ><span class="el-icon-switch-button"></span> &nbsp;退出登入</span>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>


    <el-container>
      <el-aside :width="isOpen==true?'64px':'200px'">
        <div class="toggle-btn" @click="toggleMenu">|||</div>
        <el-menu
          :collapse="isOpen"
          :router="true"
          :default-active="activePath"
          background-color="#001529"
          :collapse-transition="false"
          text-color="rgba(255,255,255,0.7)"
          unique-opened
          :default-openeds="['1']"
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-setting"></i>
              <span slot="title">系统管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1" @click="goProfile" class="el-icon-star-off">
                系统首页
              </el-menu-item>
              <el-menu-item index="1-2" @click="toEmpList" class="el-icon-s-home">
                部门管理
              </el-menu-item>
              <el-menu-item index="1-3" @click="toUserList" class="el-icon-user">
                用户管理
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-files"></i>
              <span slot="title">业务管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1" class="el-icon-plus">
                视频上传
              </el-menu-item>
              <el-menu-item index="2-2" @click="goVideoList" class="el-icon-document">
                视频分类
              </el-menu-item>
              <el-menu-item index="2-3"  class="el-icon-edit">
                视频管理
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-menu-item index="3" disabled>
            <i class="el-icon-document"></i>
            <span slot="title">导航三</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-location"></i>
            <span slot="title">导航四</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <el-main>
        <router-view/>
      </el-main>

    </el-container>
    </el-container>
</template>
<script>
  import MenuTree from "./MenuTree.vue"; //引进菜单模板
  export default {
    data() {
      return {
        loading: true,
        activePath: "", //激活的路径
        isOpen: false,
        menuList: {},
        userInfo: {},
      }
    },
    components: {
      MenuTree
    },
    methods:{
      goProfile(){
        this.$router.push("/WelCome")
      },
      async logout(){
        let res = await this.$confirm("此操作将退出系统, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).catch(() => {
          this.$message({
            type: "info",
            message: "已取消退出登入"
          });
        });
        if (res == "confirm") {
          window.localStorage.clear();
          await this.$router.push("/");
        }
      },
      toUserList(){
        this.$router.push("/user/userlist")
      },
      toEmpList(){
        this.$router.push("/user/department")
      },
      toggleMenu() {
        this.isOpen = !this.isOpen;
      },
      goVideoList(){
        this.$router.push("/video/videolist")
      }
    },
    // props: ['username'],
    name: "Main",

  }
</script>

<style scoped lang="scss">

  .el-header {
    background-color: #88d1c7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    font-size: 19px;
    padding-left: 0px;
  }
  .home-container {
    width: 100%;
    height: 100% !important;
  }
  .toggle-btn {
    background-color: #2d8cf0 !important;
    font-size: 10px;
    line-height: 24px;
    color: #fff;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer;
  }
  .el-aside {
    height: 100%;
  }
</style>
